//
//  UIButton+Extension.swift
//  XJWeiBo
//
//  Created by 李旭杰 on 2017/4/4.
//  Copyright © 2017年 李旭杰. All rights reserved.
//

import UIKit

extension UIButton {
    convenience init(title: String, imageName: String?, target: Any, action: Selector) {
        self.init()
        /// 设置标题
        setTitle(title, for: .normal)
        /// 标题颜色
        setTitleColor(UIColor.darkGray, for: .normal)
        /// 标题字号
        self.titleLabel?.font = UIFont.systemFont(ofSize: 12)
        if imageName != nil {
            /// 设置图片
            setImage(UIImage(named: imageName ?? ""), for: .normal)
        }
        /// 监听标题的点击事件
        addTarget(target, action: action, for: .touchUpInside)
    }
}
